Skip to content

BE-930: Add memory, thread and disk limits to the workspace - #10003

Merged
montekki merged 1 commit into
mainfrom
asa/hash-integrations/04b-engine-limits
Oct 28, 2026
Merged

montekki merged 1 commit into
mainfrom
asa/hash-integrations/04b-engine-limits

Conversation

@thehabbos007

Copy link
Copy Markdown
Contributor

🌟 Purpose

This PR lets a caller limit a workspace's memory, threads and disk use through WorkspaceConfig.

🔍 Changes

  • memory_limit, temp_directory_limit and threads set DuckDB's memory_limit, max_temp_directory_size and threads settings.
  • disk_limit limits the combined size of the database file, its log and DuckDB's temporary directory. The workspace checks it on open and after each query and create_table. When the files are over the limit, it checkpoints the log into the database file and measures again before it fails with DiskLimit.

⚠️ Known issues

  • The check runs after a statement, so one create_table can write past the limit, and the table it created stays in the database.

@thehabbos007 thehabbos007 self-assigned this Oct 12, 2026
@github-actions github-actions Bot added area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team area/tests New or updated tests area/apps > hash-integrations labels Oct 12, 2026
@thehabbos007
thehabbos007 added this pull request to stack #9985 October 12, 2026 14:49
@vercel

vercel Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hash Ready Ready Preview Oct 28, 2026 11:26am UTC
petrinaut Ready Ready Preview Oct 28, 2026 11:26am UTC
petrinaut-docs Ready Ready Preview Oct 28, 2026 11:26am UTC
1 Skipped Deployment
Project Deployment Actions Updated
hashdotdesign-tokens Ignored Ignored Preview Oct 28, 2026 11:26am UTC

Request Review

@codecov

codecov Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.84536% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.12%. Comparing base (af7f90f) to head (c4e7a97).

Files with missing lines Patch % Lines
...al/integrations/engine/src/workspace/connection.rs 93.97% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10003      +/-   ##
==========================================
+ Coverage   68.10%   68.12%   +0.01%     
==========================================
  Files        2034     2035       +1     
  Lines      207919   207996      +77     
  Branches     9032     9039       +7     
==========================================
+ Hits       141612   141689      +77     
  Misses      64548    64548              
  Partials     1759     1759              
Flag Coverage Δ
hash-integrations-engine 91.13% <94.84%> (+1.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@thehabbos007
thehabbos007 force-pushed the asa/hash-integrations/04b-engine-limits branch from b241522 to 8f8ddc7 Compare October 13, 2026 07:45
@thehabbos007
thehabbos007 force-pushed the asa/hash-integrations/04b-engine-limits branch from 8f8ddc7 to fe46e4a Compare October 13, 2026 09:05
@thehabbos007
thehabbos007 force-pushed the asa/hash-integrations/04b-engine-limits branch from fe46e4a to 29f3584 Compare October 13, 2026 10:15
@thehabbos007
thehabbos007 force-pushed the asa/hash-integrations/04b-engine-limits branch from 29f3584 to 9812312 Compare October 13, 2026 19:53
@montekki
montekki force-pushed the asa/hash-integrations/04b-engine-limits branch from 3c8acb8 to 100b5ef Compare October 19, 2026 12:34
@montekki
montekki force-pushed the asa/hash-integrations/04b-engine-limits branch from 100b5ef to 1a598d5 Compare October 19, 2026 12:45
@montekki
montekki force-pushed the asa/hash-integrations/04b-engine-limits branch from 1a598d5 to 9888ede Compare October 21, 2026 11:41
@montekki
montekki force-pushed the asa/hash-integrations/04b-engine-limits branch from 9888ede to 1a45678 Compare October 21, 2026 11:50
@montekki
montekki removed this pull request from stack #9985 October 22, 2026 12:52
@montekki
montekki added this pull request to stack #10170 October 22, 2026 12:56
@thehabbos007
thehabbos007 force-pushed the asa/hash-integrations/04b-engine-limits branch from 1a45678 to be813a1 Compare October 26, 2026 20:50
Copilot AI balanced review requested due to automatic review settings October 26, 2026 20:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Disk accounting measures symbolic links rather than their targets, allowing oversized workspace files to pass the configured limit.

1 open issue
What changed in this PR

Adds configurable resource limits to the integration engine’s DuckDB workspaces through WorkspaceConfig.

Changes:

  • Configures DuckDB memory, temporary-disk, and thread limits.
  • Checks combined database, log, and temporary-file usage on open and after statements, checkpointing before reporting excess usage.
  • Adds public size and error types, documentation, and integration tests.
File Description
libs/​@local/​integrations/​engine/​tests/​workspace.rs Tests settings, disk accounting, checkpointing, and retained tables.
libs/​@local/​integrations/​engine/​src/​workspace/​mod.rs Exposes resource settings and documents limit errors.
libs/​@local/​integrations/​engine/​src/​workspace/​files.rs Identifies paths included in disk accounting.
libs/​@local/​integrations/​engine/​src/​workspace/​error.rs Adds settings identifiers and disk-limit errors.
libs/​@local/​integrations/​engine/​src/​workspace/​connection.rs Applies settings and enforces post-statement disk checks.
libs/​@local/​integrations/​engine/​src/​lib.rs Exports the new public types.
libs/​@local/​integrations/​engine/​src/​byte_size.rs Introduces a byte-size type for limits and reporting.

Review effort: Balanced

Comment thread libs/@local/integrations/engine/src/workspace/connection.rs
montekki
montekki previously approved these changes Oct 28, 2026
montekki
montekki previously approved these changes Oct 28, 2026

This branch was successfully deployed

3 active deployments
Preview – petrinaut-docs — c4e7a972 Deployed Oct 28, 2026 by vercel[bot]
Preview – hash — c4e7a972 Deployed Oct 28, 2026 by vercel[bot]
Preview – petrinaut — c4e7a972 Deployed Oct 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apps > hash-integrations area/libs Relates to first-party libraries/crates/packages (area) area/tests New or updated tests type/eng > backend Owned by the @backend team

Development

Successfully merging this pull request may close these issues.

3 participants